<?$gn = Group::group_names();?>
<div style="margin:10px">
<h1>Users management</h1>
<div>
    Danh sách người dùng | <a href="index.php?m=admin_users&a=create">Tạo người dùng mới</a>
</div>

<table>
   <tr>
       <th>ID</th>
       <th>User_name</th>
       <th>User_email</th>
       <th>User_realname</th>
       <th>User_group</th>
       <th>Action</th>
   </tr>
   <?foreach($users as $u):?>
   <?$group_name = (key_exists($u['group_id'],$gn))? $gn[$u['group_id']] : '<i>Unassigned</i>'; ?>
   <tr>
       <td><?=$u['user_id']?></td>
       <td><?=$u['user_name']?></td>
       <td><?=$u['user_email']?></td>
       <td><?=$u['user_realname']?></td>
       <td><?=$group_name?></td>
       <td><a href="index.php?m=admin_users&a=edit&user_id=<?=$u['user_id']?>">Edit</a> |<a href="javascript:deleteUser(<?=$u['user_id']?>)" >Delete</a></td>
   </tr>
   <?endforeach?>
</table>
</div>

<script type="text/javascript">

function deleteUser(userid){

    var conf = confirm("Are you sure you want to delete this user?");
    if(conf == true){
         var url="index.php?m=admin_users&a=delete&user_id="+userid;
         window.location=url;
         //alert (url);
    }

}

</script>